package cn.wolfcode.wolf2w.controller;


import cn.wolfcode.wolf2w.annotation.RequireLogin;
import cn.wolfcode.wolf2w.domain.*;
import cn.wolfcode.wolf2w.redis.service.IUserinfoRedisService;
import cn.wolfcode.wolf2w.service.*;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sun.security.krb5.internal.crypto.Des;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/destinations")
public class DestinationController {

    @Autowired
    private IRegionService regionService;
    @Autowired
    private IDestinationService destinationService;
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private IStrategyCatalogService strategyCatalogService;
    @Autowired
    private ITravelService travelService;

    @GetMapping("/hotRegion")
    public Object hotRegion() {
        List<Region> list = regionService.getIsHot();
        return JsonResult.success(list);
    }

    @GetMapping("/list")
    public Object list() {
        List<Destination> list = destinationService.list();
        return JsonResult.success(list);
    }


    @GetMapping("/search")
    public Object search(String regionId) {
        List<Destination> list = new ArrayList<>();
        list = destinationService.getDestByRegionIdForapi(regionId);
        return JsonResult.success(list);
    }

    @GetMapping("/toasts")
    public Object toasts(String destId) {

        List<Destination> destinations = destinationService.queryToasts(destId);
        return JsonResult.success(destinations);
    }

    @GetMapping("/catalogs")
    public Object catalogs(String destId) {

        List<StrategyCatalog> strategies = strategyCatalogService.getByDestId(destId);
        return JsonResult.success(strategies);
    }

    @GetMapping("/strategies/viewnumTop3")
    public Object viewnumTop3(String destId) {
        List<Strategy> strategies = strategyService.viewnumTop3(destId);
        return JsonResult.success(strategies);
    }

    @GetMapping("/travels/viewnumTop3")
    public Object travelsViewnumTop3(String destId) {
        return JsonResult.success(travelService.viewnumTop3(destId));
    }
}
